package com.cmcc.example.face.withSdk.controller;

import com.chinamobile.bcop.api.sdk.exception.ClientException;
import com.cmcc.example.face.common.vo.ResultVO;
import com.cmcc.example.face.noSdk.common.vo.response.EcloudBaseResponseVO;
import com.cmcc.example.face.withSdk.service.SdkFaceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * <p>
 * <name>SdkFaceController</name>
 * 调用sdk人脸检查相关接口
 * </p >
 *
 * @author arabira
 * @version 1.0 2020-04-03
 * @since 1.0
 */
@Slf4j
@RestController
@RequestMapping("/sdk/face")
public class SdkFaceController {

    @Autowired
    private SdkFaceService faceService;

    /**
     * 人脸比对
     * @param image1
     * @param image2
     * @return
     */
    @RequestMapping(value = "/matcher", method = RequestMethod.POST)
    public ResultVO faceMatcher(@RequestParam("img1") MultipartFile image1, @RequestParam("img2") MultipartFile image2) throws IOException, ClientException {
        log.info("sdk -> 接收到两张对比图片 image1:{} image2:{}", image1.getOriginalFilename(), image2.getOriginalFilename());
        EcloudBaseResponseVO responseVO = faceService.matcher(image1, image2);
        return ResultVO.success(responseVO);
    }
}